import Vue from 'vue'
import Vuex from 'vuex'
import persist from 'vuex-persist'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    shop:[],
  },
  mutations: {
    ADD(state,item){
      let flag = true;
      state.shop.forEach(items=>{
        if(items.id == item.id){
          items.num ++;
          flag = false;
        }
      })
      if(flag == true){
        state.shop.push(item)
      }
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [
    new persist({
        storage: window.localStorage,
    }).plugin,
],
})
